package com.tianji.promotion.utils;

import com.tianji.promotion.enums.MyLockType;
import org.springframework.core.annotation.Order;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.concurrent.TimeUnit;

@Target(value = ElementType.METHOD)
@Retention(value = RetentionPolicy.RUNTIME)
public @interface MyLock {
    String key(); //分布式锁的键

    long waitTime() default 1; //分布式锁的等待时间

    long leaseTime() default -1; //分布式锁的失效时间

    TimeUnit unit() default TimeUnit.SECONDS;

    MyLockType type() default MyLockType.RE_ENTRANT_LOCK; //锁的类型

    MyLockStrategy strategy() default MyLockStrategy.FAIL_AFTER_RETRY_TIMEOUT; //锁的策略
}
